home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / finderdragpro / finderdragpro.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  4.3 KB  |  154 lines

  1. /*
  2.     File:        FinderDragPro.h
  3.     
  4.     Description:     Sample file illustrating drag and drop techniques for use
  5.                 with file system objects.  This file illustrates how applications
  6.                 can use drag and drop commands in a way compatible with current
  7.                 and past versions of the Finder.
  8.  
  9.     Author:        John Montbriand
  10.  
  11.     Copyright:     Copyright: © 1999 by Apple Computer, Inc.
  12.                 all rights reserved.
  13.     
  14.     Disclaimer:    You may incorporate this sample code into your applications without
  15.                 restriction, though the sample code has been provided "AS IS" and the
  16.                 responsibility for its operation is 100% yours.  However, what you are
  17.                 not permitted to do is to redistribute the source as "DSC Sample Code"
  18.                 after having made changes. If you're going to re-distribute the source,
  19.                 we require that you make it clear in the source that the code was
  20.                 descended from Apple Sample Code, but that you've made changes.
  21.     
  22.     Change History (most recent first):
  23.     9/9/99 by John Montbriand
  24. */
  25.  
  26. #ifndef __FINDERDRAGPRO__
  27. #define __FINDERDRAGPRO__
  28.  
  29. #include <MacTypes.h>
  30. #include <Drag.h>
  31.  
  32.     /* apple menu constants */
  33. enum {
  34.     mApple = 128,
  35.     iAbout = 1,
  36.     iFirstAppleItem = 3
  37. };
  38.  
  39.     /* file menu constants */
  40. enum {
  41.     mFile = 129,
  42.     iNew = 1,
  43.     iOpen = 2,
  44.     iClose = 3,
  45.     iSave = 5,
  46.     iSaveAs = 6,
  47.     iRevert = 7,
  48.     iPageSetup = 9,
  49.     iPrint = 10,
  50.     iQuit = 12
  51. };
  52.  
  53.     /* edit menu constants */
  54. enum {
  55.     mEdit = 130,
  56.     iUndo = 1,
  57.     iCut = 3,
  58.     iCopy = 4,
  59.     iPaste = 5,
  60.     iClear = 6
  61. };
  62.  
  63. enum {    /* the main menu bar resource */
  64.     kFDPMenuBarResource = 128
  65. };
  66.  
  67.     /* main window dialog constants */
  68. enum {
  69.     kFDPDialogResource = 128,
  70.     kFDPUserItem = 1,
  71.     kFDPhfsItem = 2,
  72.     kFDPpromiseItem = 3,
  73.         /* kUsePromiseHFS and kUseRegularHFS are used for
  74.         internal tracking of the state of the kFDPhfsItem and
  75.         the kFDPpromiseItem dialog controls. */
  76.     kUsePromiseHFS = 100, /* output promise hfs flavors in drags */
  77.     kUseRegularHFS = 101,/* output hfs flavors in drags */
  78.     kFDPDragItemID = 392 /* item identifier for our drags */
  79. };
  80.  
  81. enum {    /* picture displayed when selection is empty */
  82.     kFDPSpashPictResource = 128
  83. };
  84.  
  85.     /* constants for the copy progress dialog */
  86. enum {
  87.     kCopyProgressTicksOffset = 50, /* 50 ticks before the progress box pops up */
  88.     kCopyProgressDialog = 130,
  89.     kPlainCopyProgressDialog = 131,
  90.     kCProCancelItem = 1,
  91.     kCProIndicatorItem = 2
  92. };
  93.  
  94.     /* alert id numbers */
  95. enum {
  96.     kCannotCopyDirAlert = 132,
  97.     kCopyFailedAlert = 133,
  98.     kDragFailedAlert = 134,
  99.     kOpenAppFailedAlert = 135,
  100.     kMainFailedAlert = 136,
  101.     kAboutBoxAlert = 137,
  102.     kNoDragManagerAlert = 138,
  103.     kNoThreadManagerAlert = 139
  104. };
  105.  
  106.  
  107.     /* promise flavor types */
  108. enum {
  109.     kPromisedFlavor = 'fssP',        /* default promise */
  110.     kPromisedFlavorFindFile = 'rWm1' /* Find File promise -- special case */
  111. };
  112.  
  113.     /* internal error codes.  Operating system errors are
  114.     negative.  We use positive ones for our own internal errors.  */
  115. enum {
  116.     kNoDragMgrError = 1235, /* drag manager not installed */
  117.     kNoThreadMgrError = 1236 /* thread manager not installed */
  118. };
  119.  
  120. enum {
  121.         /* sleep value passed to WaitNextEvent.  Normally
  122.         we'll delay for 1 second between events, unless
  123.         we're performing a file copy. */ 
  124.     kNormalSleepTime = (1*60), /* normal operation -> 1 second */
  125.     kCopySleepTime = 0 /* during copies -> return as soon as possible */
  126. };
  127.  
  128.  
  129. /* routine prototypes */
  130.  
  131. /* ProcessNextEvent calls WaitNextEvent to get the next event and then it passes
  132.     the event along to the HandleNextEvent routine.  sleepTime is passed to the
  133.     WaitNextEvent routine in the sleep parameter. */
  134. void ProcessNextEvent(long sleepTime);
  135.  
  136.  
  137. /* ParamAlert is a general alert handling routine.  If Apple events exist, then it
  138.     calls AEInteractWithUser to ensure the application is in the forground, and then
  139.     it displays an alert after passing the s1 and s2 parameters to ParamText. */
  140. short ParamAlert(short alertID, StringPtr s1, StringPtr s2);
  141.  
  142.  
  143. /* SetNewDisplay is called to set the file or folder being displayed in the main window.
  144.     Here, structures are deallocated and an alias is saved referring to the file. 
  145.     SetNewDisplay is called from the drag receive handler and since it is not
  146.     safe to call "GetIconSuiteFromFinder()" from inside of the drag receive handler
  147.     (it uses apple events), the flag gFileUpToDate is used to defer that operation
  148.     until the next time ValidateFDPWindowDisplay.  ValidateFDPWindowDisplay is
  149.     called from the main loop.  If targetFile is NULL, then the display is cleared. */
  150. void SetNewDisplay(HFSFlavor *targetFile);
  151.  
  152.  
  153. #endif
  154.